
import React from "react"
import Appcss1 from "./css/Reg.module.css"
import fanh from '../../assets/icons/返回箭头.png'
import nicheng from '../../assets/icons/昵称.png'
import { List,  InputItem} from 'antd-mobile';
import { Toast, WhiteSpace, WingBlank, Button } from 'antd-mobile';
// import { createForm } from 'rc-form';
// import Logo from '../assets/icons/logo.png'
class Name extends React.Component {
    constructor(){
        super()
        this.state={
            phone:"",
            mima:"",
            name:""
        }
    }
    ipt1(e){
        // var uPattern = /^[a-zA-Z0-9_-]{4,16}$/;
        // if(!uPattern.test(e.target.value)){
        this.setState({
            name:e.target.value,
        })
    // }else{
    //         alert(1111)
    //     }

    }
    send(){
        fetch(`http://106.12.10.151:3000/activate/init/profile?nickname=${this.state.name}`,{  credentials:'include'})
        .then(body=>body.json())
        .then(res=>{
            if(res.code==200){
                Toast.loading('success...', 1, () => {
                    this.props.history.push({pathname:"/login"})
                  });
               
            }
            else{
                Toast.fail('输入错误', 1); 
            }
        })
        // .catch(
        //     Toast.fail('账号或密码错误', 1);
        // )
    }
    fanhu(){
        this.props.history.push({pathname:"/password"})
    }
    render(){
        return(
           
        <div className={Appcss1.cel_name}>

             <div className={Appcss1.cel_zc}>
                <span id={Appcss1.cel_fh} onClick={this.fanhu.bind(this)}><img src={fanh} width='100%' height='100%' alt=''/></span>
                <span id={Appcss1.cel_reg}>给自己取一个昵称</span>
                
            </div>
            <div className={Appcss1.nicheng}>
            <img src={nicheng} width='100%' height='100%' alt=''/>
             </div>
             <div >
               <input type="text" className={Appcss1.cel_pa} placeholder="请输入昵称"  onChange={this.ipt1.bind(this)} value={this.state.name}></input>
             </div>
             
            
			<button className={Appcss1.cel_re} onClick={this.send.bind(this)}>开启云音乐</button><br/>
            {/* <span className={Appcss.cel_qtdl}>&lt;其他登录方式</span> */}
		</div>
    
        )
    }



}
// const Cell_login1 = createForm()(Cell_login);
export default Name